package com.dhcc.utils.array;

import java.lang.reflect.Array;

import com.dhcc.utils.Operator;

public class JoinOperator implements Operator<Object> {

	@Override
	public Object invoke(String operator, Object first, Object[] args) {
		StringBuilder builder = new StringBuilder();
		int len = Array.getLength(first);
		String sep = String.valueOf(args[0]);
		for (int i = 0; i < len; i++) {
			builder.append(Array.get(first, i));
			builder.append(sep);
		}
		if(len>0){
			builder.setLength(builder.length()-sep.length());
		}
		return builder.toString();
	}

}
